import 'package:shared_preferences/shared_preferences.dart';

class DnpCacheManager {

  static final DnpCacheManager _instance = DnpCacheManager._internal();
  static SharedPreferences? _prefs;

  factory DnpCacheManager() {
    return _instance;
  }

  DnpCacheManager._internal() {
    _init();
  }

  void _init() async {
    _prefs = await SharedPreferences.getInstance();
  }

  void saveString(String key, String value) {
    _prefs?.setString(key, value);
  }

  void saveInt(String key, int value) {
    _prefs?.setInt(key, value);
  }

  void saveBool(String key, bool value) {
    _prefs?.setBool(key, value);
  }

  void saveDouble(String key, double value) {
    _prefs?.setDouble(key, value);
  }

  String? getString(String key) {
    return _prefs?.getString(key);
  }

  int getInt(String key) {
    return _prefs?.getInt(key) ?? 0;
  }

  bool getBool(String key) {
    return _prefs?.getBool(key) ?? false;
  }

  double getDouble(String key) {
    return _prefs?.getDouble(key) ?? 0.0;
  }

}




